package com.gary.component;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.Random;

/**
 * Author：gary
 * <p/>
 * Email: xuhaozv@163.com
 * <p/>
 * description:
 * <p/>
 * Date: 2018/3/30 下午12:14
 */
public class FirstSwipeBackFragment extends BaseFragment {

    private Toolbar mToolbar;

    public static FirstSwipeBackFragment newInstance(int i) {

        Bundle args = new Bundle();
        args.putInt("po",i);
        FirstSwipeBackFragment fragment = new FirstSwipeBackFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_swipe_back_first, container, false);

        mToolbar = (Toolbar) view.findViewById(R.id.toolbar);
        mToolbar.setTitle("SwipeBackActivity's Fragment"+new Random().nextInt(100));
        _initToolbar(mToolbar);

        view.findViewById(R.id.btn).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                start(FirstSwipeBackFragment.newInstance(2));
            }
        });
        if(getArguments() !=null && getArguments().getInt("po") == 1){
            setSwipeBackEnable(false);
        }

        return attachToSwipeBack(view);
    }
}
